<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset={$charset}" />
        <title>提现管理</title>
        {''|getCommon} 
		{'easyui'|getPlugSingle}
		{'ztree'|getPlugSingle}
		{'uploadify'|getPlugSingle}
	</head>
    <body>
    	<style>
    		{literal}
    			.uploadAvaterBtn{border:1px solid #ddd;height:20px;}
    			#showPhoto{width:100px;height:100px;margin-top:5px;display:table-cell;text-align:center;vertical-align:middle;}
    			#showUpdateUserPhoto{width:100px;height:100px;margin-top:5px;display:table-cell;text-align:center;vertical-align:middle;}
    		{/literal}
    	</style>
    	
        <table id="userTable" title="提现管理" style="width:100%;"
				data-options="rownumbers:true,singleSelect:true,pagination:true,url:'queryWithdInfo',method:'post',toolbar:'#userTableTool',multiSort:false">
			<thead>
				<tr>
					<th data-options="field:'withdId'" width="10%">提现ID</th>
					<th data-options="field:'withdMo'" width="8%">提现金额</th>
					<th data-options="field:'withdCounterMo',align:'left'" width="8%">手续费</th>
					<th data-options="field:'withdTotalMo',align:'left'" width="8%">总计金额</th>
					<th data-options="field:'userLoginId'" width="10%">提现用户</th>
					<th data-options="field:'withdCreatetime',align:'left'" width="12%">提现时间</th>
					<th data-options="field:'withdPassTime',align:'left'" width="12%">审核时间</th>
					<th data-options="field:'withdState',align:'left',formatter:withState" width="10%">当前状态</th>
					<th data-options="field:'_op',align:'left',formatter:rowOp" width="21%">操作</th>
				</tr>
			</thead>
		</table>
		<div id="userTableTool" style="padding:5px;height:auto">
			<div>
				<div style="margin-bottom:5px">
					<a href="#" class="easyui-linkbutton" iconCls="icon-reload" plain="true" onclick="javascript:window.location.reload()">刷新</a>
				</div>
				<form id="queryWithInfo" method="post">
					提现时间: <input class="easyui-datebox" name="withdCreatetimeStart" style="width:80px">
					到: <input class="easyui-datebox" name="withdCreatetimeEnd" style="width:80px">
					当前状态: 
					<select class="easyui-combobox" name="withdState" panelHeight="auto" style="width:100px">
						<option value="4">所有</option>
						<option value="1">待审核中</option>
						<option value="2">审核通过</option>
						<option value="3">审核失败</option>
					</select>
					<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="queryTableInfo()">搜索</a>
					<a href="#" class="easyui-linkbutton" iconCls="icon-redo" onclick="clearQueryForm()">清空条件</a>
				</form>
			</div>
		</div>
		
		{literal}
	<div id="detail-dialog" class="easyui-dialog"
		style="width: 800px; height: 250px; visibility: hidden;"closed="true"
		data-options="title:'详情',modal:true,buttons:[{
				text:'关闭',
				handler:function(){
					$('#detail-dialog').dialog('close');
				}
			}]">
		<table id="dialogList" class="easyui-datagrid" style="width: 780px;height:150px;"
			data-options="collapsible:true,rownumbers:true,singleSelect:true,url:'queryWithdInfo',method:'post'">
			<thead>
				<tr>
					<th data-options="field:'withBankNo'" width="20%">银行卡卡号</th>
					<th data-options="field:'withBankName'"width="20%">所属银行</th>
					<th data-options="field:'withBankAccount',resizable:true" width="20%">开户支行</th>
					<th data-options="field:'withBankUserName',resizable:true" width="20%">持有人姓名</th>
				</tr>
			</thead>
		</table>
	</div>
	{/literal}
		<script type="text/javascript">
			var SITE_GLOBAL_URL = '{$smarty.const.SITE_GLOBAL_URL}';
		</script>
		<script type="text/javascript">
			{literal}
			//状态解释器
			function withState(val,row){
				switch(val){
					case '1':
						return '<span style="color:green;">待审核中</span>';
						break;
					case '2':
						return '<span style="color:green;">审核通过</span>';
						break;
					case '3':
						return '<span style="color:#FF5300;">审核失败</span>';
						break;
					default:
						return '<span style="color:#333333;">-</span>';
						break;
				}
			}
			
			
			//对每行的操作自定义
			function rowOp(val,row){
				var html = '';
				//如果是启动的就开启锁定按钮和封号按钮
				if(row.withdState == 1){
					html += '<a href="#" onclick="updateWithSta('+row.withdId+',2)">审核通过</a>';
					html += '<a href="#" onclick="updateWithSta('+row.withdId+',3)">审核失败</a>';
					html += '<a href="#" onclick="queryDetail('+row.withdId+')">详情</a>';
				}else if(row.withdState == 2){
					html += '<a href="#" onclick="queryDetail('+row.withdId+')">详情</a>';
				}else if(row.withdState == 3){
					html += '<a href="#" onclick="queryDetail('+row.withdId+')">详情</a>';
				}else{
					html += '<a href="#" onclick="queryDetail('+row.withdId+')">详情</a>';
				}
				return html;
			}
			//详情
			function queryDetail(id){
				$('#detail-dialog').dialog('open');
				$('#detail-dialog').css("visibility", "visible");
				$('#dialogList').datagrid('load', {
					withdId: id,
					page:1,
					rows:1
				});
			}
			
			//修改状态
			function updateWithSta(withdId,withdState){	
				$.messager.confirm('提醒', '你是否确认操作？', function(r){
					if(r){	
					$.post('updateWithdInfoSta',{'withdId':withdId,'withdState':withdState},function(data){
						eval('var dataJson = '+data);
						if(dataJson.result==true){
							$.messager.show({
								title : '提示',
								msg :'操作成功!'
							});
							$('#userTable').datagrid();
						}else{
							$.messager.show({
								title : '提示',
								msg :'操作失败，请重试!'
							});
						}
					});
					}
				});
			
			}
			
			//带条件查询信息
			function queryTableInfo(){
				$("#userTable").datagrid("load", {
					withdCreatetimeStart:$('#queryWithInfo input[name="withdCreatetimeStart"]').val(),
					withdCreatetimeEnd:$('#queryWithInfo input[name="withdCreatetimeEnd"]').val(),
					withdState:$('#queryWithInfo input[name="withdState"]').val()
		        });
			}
			
			//清空条件
			function clearQueryForm(){
				$('#queryWithInfo').form('clear');
			}
			
			$(function(){
				var pager = $('#userTable').datagrid({
					method: 'POST',
					loadMsg: '数据加载中,请稍候...',
					pagination: true,   
					pageSize: 15,//每页显示的记录条数，默认为10 
					pageList: [15, 30, 45]//可以设置每页记录条数的列表  
				}).datagrid('getPager');	// get the pager of datagrid
				pager.pagination({
					pageSize: 15,//每页显示的记录条数，默认为20
					pageList: [15,30,45] //可以设置每页记录条数的列表 
				});			
			})
			{/literal}
		</script>
    </body>
</html>
